//
//  InpCostCell.m
//  掌上宏力
//
//  Created by admin on 2017/5/17.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "InpCostCell.h"
#import "InpCostsModel.h"

static CGFloat Lab_H = 30;

@interface InpCostCell ()
/*

 \"ITEM_NAME\": \"0.9%氯化钠注射液\",
 \"UNITS\": \"瓶\",
 \"AMOUNT\": 2,
 \"ITEM_PRICE\": 3.10,
 \"COSTS\": 6.20,
 \"FEE_CLASS_NAME\": \"西药费\",

 
 @property (nonatomic,copy) NSString *name;
 @property (nonatomic,copy) NSString *units;
 @property (nonatomic,copy) NSNumber *amount;
 @property (nonatomic,copy) NSNumber *singlPrice;
 @property (nonatomic,copy) NSNumber *costPrice;
 @property (nonatomic,copy) NSString *type;
 */
@property (nonatomic,weak) UILabel *nameLab;
@property (nonatomic,weak) UILabel *amountLab;
@property (nonatomic,weak) UILabel *singlePriceLab;
@property (nonatomic,weak) UILabel *costPriceLab;
@property (nonatomic,weak) UILabel *typeLab;

@end

@implementation InpCostCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UILabel *typeLab = [[UILabel alloc] initWithFrame:CGRectMake(LeftDis, 5, kScreenW-20, Lab_H)];
        [self.contentView addSubview:typeLab];
        self.typeLab = typeLab;
        
        UILabel *nameLab = [[UILabel alloc] initWithFrame:CGRectMake(LeftDis, typeLab.bottom, kScreenW-20, Lab_H)];
        nameLab.font = kFont(16);
        [self.contentView addSubview:nameLab];
        self.nameLab = nameLab;
        
        UILabel *amountLab = [[UILabel alloc] initWithFrame:CGRectMake(LeftDis, nameLab.bottom, 100, Lab_H)];
        amountLab.font = kFont(15);
        [self.contentView addSubview:amountLab];
        self.amountLab = amountLab;
        
        UILabel *singlePriceLab = [[UILabel alloc] initWithFrame:CGRectMake(amountLab.right, nameLab.bottom, kScreenW-120, Lab_H)];
        singlePriceLab.font = kFont(15);
        [self.contentView addSubview:singlePriceLab];
        self.singlePriceLab = singlePriceLab;
    }
    return self;
}

-(void)setCostInfo:(InpCostsModel *)costInfo{
    self.typeLab.text = [NSString stringWithFormat:@"%@:    %@ 元",costInfo.type,costInfo.costPrice];
    self.nameLab.text = costInfo.name;
    self.amountLab.text = [NSString stringWithFormat:@"数量：%@",costInfo.amount];
    self.singlePriceLab.text = [NSString stringWithFormat:@"单价：%@元/%@",costInfo.singlPrice,costInfo.units];
//    self.costPriceLab.text = [NSString stringWithFormat:@"%@ 元",costInfo.costPrice];
}
+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId = @"costCell";
    InpCostCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[InpCostCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
